from django.http import Http404
from django.shortcuts import render_to_response, get_list_or_404, get_object_or_404
from django.template import RequestContext
    
from models import Endorsement
from pr_j.models import Project

def main(request, template_name="endo/main.html"):
    """
    The endorsement list
    """
    endorsements = get_list_or_404(Endorsement)

    return render_to_response(template_name, {'endorsements':endorsements, 'nav_page':'endo_main'},
                              context_instance=RequestContext(request))

def endorsement(request, slug, template_name="endo/endorsement.html"):
    """
    An endorsement
    """
    endorsement = get_object_or_404(Endorsement, slug=slug)
    projects = get_list_or_404(Project, endorsements=endorsement)
    return render_to_response(template_name, {'endorsement':endorsement, 'projects':projects, },
                              context_instance=RequestContext(request))
